package net.siufung.market.base.permit.controller.model.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.siufung.core.model.AbstractVo;
import net.siufung.core.model.enums.DeletedEnum;
import net.siufung.core.utils.StringPool;
import net.siufung.market.base.permit.enums.AccessStates;
import net.siufung.market.base.permit.enums.BusinessTypes;
import net.siufung.market.base.permit.enums.MenuTypes;

/**
 * @author 陈建峰
 * @since 2022/8/5 2:32 下午
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="MenuTreeTableVo", description="菜单Table")
public class MenuTreeTableVo extends AbstractVo {

    private static final long serialVersionUID = -2353190704579925307L;

    /**
     * 主键id
     */
    @ApiModelProperty(value = "主键id")
    private Integer id;

    /**
     * 名称
     */
    @ApiModelProperty(value = "名称")
    private String name;

    /**
     * 编码
     */
    @ApiModelProperty(value = "编码")
    private String code;

    /**
     * 菜单父级id
     */
    @ApiModelProperty(value = "菜单父级id")
    private Integer parentId;

    /**
     * 外链状态
     */
    @ApiModelProperty(value = "外链状态")
    private Boolean externalState;

    /**
     * 链接
     */
    @ApiModelProperty(value = "外部链接")
    private String externalUrl;

    /**
     * 菜单路径
     */
    @ApiModelProperty(value = "菜单路径")
    private String router;

    /**
     * 页面缓存展示
     */
    @ApiModelProperty(value = "页面缓存")
    private Boolean keepAlive;

    /**
     * 菜单图标
     */
    @ApiModelProperty(value = "菜单图标")
    private String icon;

    /**
     * 菜单级别
     */
    @ApiModelProperty(value = "菜单级别")
    private Integer level;

    /**
     * 系统应用id
     */
    @ApiModelProperty(value = "系统应用id")
    private Integer appId;

    /**
     * 访问类型
     */
    @ApiModelProperty(value = "访问类型")
    private Boolean accessState;

    /**
     * 业务类型
     */
    @ApiModelProperty(value = "业务类型")
    private String businessType;

    /**
     * 菜单排序
     */
    @ApiModelProperty(value = "菜单排序")
    private Integer sequence;

    /**
     * 权限标识
     */
    @ApiModelProperty(value = "权限标识")
    private String sign;

    /**
     * 菜单类型
     */
    @ApiModelProperty(value = "菜单类型")
    private String menuType;

    /**
     * 菜单描述
     */
    @ApiModelProperty(value = "菜单描述")
    private String description;

    /**
     * 数据标识
     */
    @ApiModelProperty(value = "数据标识")
    private Boolean deleted;

    public String getAccessStateDesc(){
        if(MenuTypes.PERMIT.equals(MenuTypes.get(menuType))){
            return StringPool.DASH;
        }
        return AccessStates.getDesc(accessState);
    }

    public String getBusinessTypeDesc(){
        return BusinessTypes.getDesc(businessType);
    }

    public String getMenuTypeDesc(){
        return MenuTypes.getDesc(menuType);
    }

    @Override
    public boolean getAllowStatus() {
        return super.getAllowStatus();
    }

    @Override
    public String getDeletedDesc() {
        return DeletedEnum.getDesc(deleted);
    }

    @Override
    public boolean getAllowUpdate() {
        return DeletedEnum.NOT.equals(DeletedEnum.get(deleted));
    }

    public boolean getAllowHidden(){
        return MenuTypes.MENU.equals(MenuTypes.get(menuType));
    }
}
